package org.jtb.quickr;

import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

class AuthGetTokenRequest extends SignedMethodRequest {
    private String frobString;
    
    protected AuthGetTokenRequest(String baseUrl, String apiKey, String secret, String frob) throws QuickrException {
        super(baseUrl, apiKey, secret, null, "flickr.auth.getToken");
        this.frobString = frob;
    }

    protected Map<String,String> getArgs() {
        putArg("frob", frobString);

        return super.getArgs();
    }
    
    public AuthResponse execute() throws QuickrException {
        FlickrUrl furl = new SignedMethodUrl(getBaseUrl(), getArgs(), getApiKey(), getSecret(), getMethod());
        Get get = new Get(furl.getUrl());
        InputStream is = get.execute();

        AuthResponse gtres = new AuthResponse(is);        
        return gtres;
    }
}
